/**
 * Copyright (c) 2016-2021 by the respective copyright holders.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 */
package com.zsmartsystems.zigbee.zcl.clusters.price;

import java.util.Calendar;

import javax.annotation.Generated;

import com.zsmartsystems.zigbee.zcl.ZclFieldDeserializer;
import com.zsmartsystems.zigbee.zcl.ZclFieldSerializer;
import com.zsmartsystems.zigbee.zcl.protocol.ZclCommandDirection;
import com.zsmartsystems.zigbee.zcl.protocol.ZclDataType;

/**
 * Publish CO2 Value Command value object class.
 * <p>
 * Cluster: <b>Price</b>. Command ID 0x07 is sent <b>FROM</b> the server.
 * This command is a <b>specific</b> command used for the Price cluster.
 * <p>
 * The PublishCO2Value command is sent in response to a GetCO2Value command or if a new CO2
 * conversion factor is available. Clients should be capable of storing at least two instances
 * of the CO2 conversion factor, the currently active and the next one.
 * <p>
 * Code is auto-generated. Modifications may be overwritten!
 */
@Generated(value = "com.zsmartsystems.zigbee.autocode.ZigBeeCodeGenerator", date = "2020-12-25T10:11:19Z")
public class PublishCo2ValueCommand extends ZclPriceCommand {
    /**
     * The cluster ID to which this command belongs.
     */
    public static int CLUSTER_ID = 0x0700;

    /**
     * The command ID.
     */
    public static int COMMAND_ID = 0x07;

    /**
     * Provider ID command message field.
     * <p>
     * An unsigned 32-bit field containing a unique identifier for the commodity provider.
     * This field allows differentiation in deregulated markets where multiple commodity
     * providers may be available.
     */
    private Integer providerId;

    /**
     * Issuer Event ID command message field.
     * <p>
     * Unique identifier generated by the commodity provider. When new information is
     * provided that replaces older information for the same time period, this field allows
     * devices to determine which information is newer. The value contained in this field is a
     * unique number managed by upstream servers or a UTC based time stamp (UTCTime data type)
     * identifying when the Publish command was issued. Thus, newer information will have a
     * value in the Issuer Event ID field that is larger than older information.
     */
    private Integer issuerEventId;

    /**
     * Start Time command message field.
     * <p>
     * A UTCTime field to denote the time at which the CO2 value becomes valid. A start date/time
     * of 0x00000000 shall indicate that the command should be executed immediately. A start
     * date/time of 0xFFFFFFFF shall cause an existing PublishCO2Value command with the same
     * Provider ID and Issuer Event ID to be cancelled (note that, in markets where permanently
     * active price information is required for billing purposes, it is recommended that a
     * replacement/superseding PublishCO2Value command is used in place of this
     * cancellation mechanism).
     */
    private Calendar startTime;

    /**
     * Tariff Type command message field.
     * <p>
     * An 8-bit bitmap identifying the type of tariff published in this command. The least
     * significant nibble represents an enumeration of the tariff type as detailed in Table
     * D-108 (Generation Meters shall use the ‘Received’ Tariff). The most significant
     * nibble is reserved.
     */
    private Integer tariffType;

    /**
     * CO2 Value command message field.
     * <p>
     * The format and use of this field is the same as for the CO2 attribute or ReceivedCO2
     * attribute (depending on TariffType) as defined in D.4.2.2.7.9 and D.4.2.2.15.6
     * respectively. A value of 0xFFFFFFFF indicates field not used. The format and use of this
     * field is the same as for the CO2Unit attribute or ReceivedCO2Unit attribute (depending
     * on TariffType) as defined in D.4.2.2.7.10 and D.4.2.2.15.7 respectively. A value of
     * 0xFF indicates field not used. The format and use of this field is the same as for the
     * CO2TrailingDigit attribute or ReceivedCO2TrailingDigit attribute (depending on
     * TariffType) as defined in D.4.2.2.7.11 and D.4.2.2.15.8 respectively. A value of 0xFF
     * indicates field not used.
     */
    private Integer co2Value;

    /**
     * CO2 Value Unit command message field.
     */
    private Integer co2ValueUnit;

    /**
     * CO2 Value Trailing Digit command message field.
     */
    private Integer co2ValueTrailingDigit;

    /**
     * Default constructor.
     *
     * @deprecated from release 1.3.0. Use the parameterised constructor instead of the default constructor and setters.
     */
    @Deprecated
    public PublishCo2ValueCommand() {
        clusterId = CLUSTER_ID;
        commandId = COMMAND_ID;
        genericCommand = false;
        commandDirection = ZclCommandDirection.SERVER_TO_CLIENT;
    }

    /**
     * Constructor providing all required parameters.
     *
     * @param providerId {@link Integer} Provider ID
     * @param issuerEventId {@link Integer} Issuer Event ID
     * @param startTime {@link Calendar} Start Time
     * @param tariffType {@link Integer} Tariff Type
     * @param co2Value {@link Integer} CO2 Value
     * @param co2ValueUnit {@link Integer} CO2 Value Unit
     * @param co2ValueTrailingDigit {@link Integer} CO2 Value Trailing Digit
     */
    public PublishCo2ValueCommand(
            Integer providerId,
            Integer issuerEventId,
            Calendar startTime,
            Integer tariffType,
            Integer co2Value,
            Integer co2ValueUnit,
            Integer co2ValueTrailingDigit) {

        clusterId = CLUSTER_ID;
        commandId = COMMAND_ID;
        genericCommand = false;
        commandDirection = ZclCommandDirection.SERVER_TO_CLIENT;

        this.providerId = providerId;
        this.issuerEventId = issuerEventId;
        this.startTime = startTime;
        this.tariffType = tariffType;
        this.co2Value = co2Value;
        this.co2ValueUnit = co2ValueUnit;
        this.co2ValueTrailingDigit = co2ValueTrailingDigit;
    }

    /**
     * Gets Provider ID.
     * <p>
     * An unsigned 32-bit field containing a unique identifier for the commodity provider.
     * This field allows differentiation in deregulated markets where multiple commodity
     * providers may be available.
     *
     * @return the Provider ID
     */
    public Integer getProviderId() {
        return providerId;
    }

    /**
     * Sets Provider ID.
     * <p>
     * An unsigned 32-bit field containing a unique identifier for the commodity provider.
     * This field allows differentiation in deregulated markets where multiple commodity
     * providers may be available.
     *
     * @param providerId the Provider ID
     * @deprecated as of 1.3.0. Use the parameterised constructor instead to ensure that all mandatory fields are provided.
     */
    @Deprecated
    public void setProviderId(final Integer providerId) {
        this.providerId = providerId;
    }

    /**
     * Gets Issuer Event ID.
     * <p>
     * Unique identifier generated by the commodity provider. When new information is
     * provided that replaces older information for the same time period, this field allows
     * devices to determine which information is newer. The value contained in this field is a
     * unique number managed by upstream servers or a UTC based time stamp (UTCTime data type)
     * identifying when the Publish command was issued. Thus, newer information will have a
     * value in the Issuer Event ID field that is larger than older information.
     *
     * @return the Issuer Event ID
     */
    public Integer getIssuerEventId() {
        return issuerEventId;
    }

    /**
     * Sets Issuer Event ID.
     * <p>
     * Unique identifier generated by the commodity provider. When new information is
     * provided that replaces older information for the same time period, this field allows
     * devices to determine which information is newer. The value contained in this field is a
     * unique number managed by upstream servers or a UTC based time stamp (UTCTime data type)
     * identifying when the Publish command was issued. Thus, newer information will have a
     * value in the Issuer Event ID field that is larger than older information.
     *
     * @param issuerEventId the Issuer Event ID
     * @deprecated as of 1.3.0. Use the parameterised constructor instead to ensure that all mandatory fields are provided.
     */
    @Deprecated
    public void setIssuerEventId(final Integer issuerEventId) {
        this.issuerEventId = issuerEventId;
    }

    /**
     * Gets Start Time.
     * <p>
     * A UTCTime field to denote the time at which the CO2 value becomes valid. A start date/time
     * of 0x00000000 shall indicate that the command should be executed immediately. A start
     * date/time of 0xFFFFFFFF shall cause an existing PublishCO2Value command with the same
     * Provider ID and Issuer Event ID to be cancelled (note that, in markets where permanently
     * active price information is required for billing purposes, it is recommended that a
     * replacement/superseding PublishCO2Value command is used in place of this
     * cancellation mechanism).
     *
     * @return the Start Time
     */
    public Calendar getStartTime() {
        return startTime;
    }

    /**
     * Sets Start Time.
     * <p>
     * A UTCTime field to denote the time at which the CO2 value becomes valid. A start date/time
     * of 0x00000000 shall indicate that the command should be executed immediately. A start
     * date/time of 0xFFFFFFFF shall cause an existing PublishCO2Value command with the same
     * Provider ID and Issuer Event ID to be cancelled (note that, in markets where permanently
     * active price information is required for billing purposes, it is recommended that a
     * replacement/superseding PublishCO2Value command is used in place of this
     * cancellation mechanism).
     *
     * @param startTime the Start Time
     * @deprecated as of 1.3.0. Use the parameterised constructor instead to ensure that all mandatory fields are provided.
     */
    @Deprecated
    public void setStartTime(final Calendar startTime) {
        this.startTime = startTime;
    }

    /**
     * Gets Tariff Type.
     * <p>
     * An 8-bit bitmap identifying the type of tariff published in this command. The least
     * significant nibble represents an enumeration of the tariff type as detailed in Table
     * D-108 (Generation Meters shall use the ‘Received’ Tariff). The most significant
     * nibble is reserved.
     *
     * @return the Tariff Type
     */
    public Integer getTariffType() {
        return tariffType;
    }

    /**
     * Sets Tariff Type.
     * <p>
     * An 8-bit bitmap identifying the type of tariff published in this command. The least
     * significant nibble represents an enumeration of the tariff type as detailed in Table
     * D-108 (Generation Meters shall use the ‘Received’ Tariff). The most significant
     * nibble is reserved.
     *
     * @param tariffType the Tariff Type
     * @deprecated as of 1.3.0. Use the parameterised constructor instead to ensure that all mandatory fields are provided.
     */
    @Deprecated
    public void setTariffType(final Integer tariffType) {
        this.tariffType = tariffType;
    }

    /**
     * Gets CO2 Value.
     * <p>
     * The format and use of this field is the same as for the CO2 attribute or ReceivedCO2
     * attribute (depending on TariffType) as defined in D.4.2.2.7.9 and D.4.2.2.15.6
     * respectively. A value of 0xFFFFFFFF indicates field not used. The format and use of this
     * field is the same as for the CO2Unit attribute or ReceivedCO2Unit attribute (depending
     * on TariffType) as defined in D.4.2.2.7.10 and D.4.2.2.15.7 respectively. A value of
     * 0xFF indicates field not used. The format and use of this field is the same as for the
     * CO2TrailingDigit attribute or ReceivedCO2TrailingDigit attribute (depending on
     * TariffType) as defined in D.4.2.2.7.11 and D.4.2.2.15.8 respectively. A value of 0xFF
     * indicates field not used.
     *
     * @return the CO2 Value
     */
    public Integer getCo2Value() {
        return co2Value;
    }

    /**
     * Sets CO2 Value.
     * <p>
     * The format and use of this field is the same as for the CO2 attribute or ReceivedCO2
     * attribute (depending on TariffType) as defined in D.4.2.2.7.9 and D.4.2.2.15.6
     * respectively. A value of 0xFFFFFFFF indicates field not used. The format and use of this
     * field is the same as for the CO2Unit attribute or ReceivedCO2Unit attribute (depending
     * on TariffType) as defined in D.4.2.2.7.10 and D.4.2.2.15.7 respectively. A value of
     * 0xFF indicates field not used. The format and use of this field is the same as for the
     * CO2TrailingDigit attribute or ReceivedCO2TrailingDigit attribute (depending on
     * TariffType) as defined in D.4.2.2.7.11 and D.4.2.2.15.8 respectively. A value of 0xFF
     * indicates field not used.
     *
     * @param co2Value the CO2 Value
     * @deprecated as of 1.3.0. Use the parameterised constructor instead to ensure that all mandatory fields are provided.
     */
    @Deprecated
    public void setCo2Value(final Integer co2Value) {
        this.co2Value = co2Value;
    }

    /**
     * Gets CO2 Value Unit.
     *
     * @return the CO2 Value Unit
     */
    public Integer getCo2ValueUnit() {
        return co2ValueUnit;
    }

    /**
     * Sets CO2 Value Unit.
     *
     * @param co2ValueUnit the CO2 Value Unit
     * @deprecated as of 1.3.0. Use the parameterised constructor instead to ensure that all mandatory fields are provided.
     */
    @Deprecated
    public void setCo2ValueUnit(final Integer co2ValueUnit) {
        this.co2ValueUnit = co2ValueUnit;
    }

    /**
     * Gets CO2 Value Trailing Digit.
     *
     * @return the CO2 Value Trailing Digit
     */
    public Integer getCo2ValueTrailingDigit() {
        return co2ValueTrailingDigit;
    }

    /**
     * Sets CO2 Value Trailing Digit.
     *
     * @param co2ValueTrailingDigit the CO2 Value Trailing Digit
     * @deprecated as of 1.3.0. Use the parameterised constructor instead to ensure that all mandatory fields are provided.
     */
    @Deprecated
    public void setCo2ValueTrailingDigit(final Integer co2ValueTrailingDigit) {
        this.co2ValueTrailingDigit = co2ValueTrailingDigit;
    }

    @Override
    public void serialize(final ZclFieldSerializer serializer) {
        serializer.serialize(providerId, ZclDataType.UNSIGNED_32_BIT_INTEGER);
        serializer.serialize(issuerEventId, ZclDataType.UNSIGNED_32_BIT_INTEGER);
        serializer.serialize(startTime, ZclDataType.UTCTIME);
        serializer.serialize(tariffType, ZclDataType.BITMAP_8_BIT);
        serializer.serialize(co2Value, ZclDataType.UNSIGNED_32_BIT_INTEGER);
        serializer.serialize(co2ValueUnit, ZclDataType.ENUMERATION_8_BIT);
        serializer.serialize(co2ValueTrailingDigit, ZclDataType.BITMAP_8_BIT);
    }

    @Override
    public void deserialize(final ZclFieldDeserializer deserializer) {
        providerId = (Integer) deserializer.deserialize(ZclDataType.UNSIGNED_32_BIT_INTEGER);
        issuerEventId = (Integer) deserializer.deserialize(ZclDataType.UNSIGNED_32_BIT_INTEGER);
        startTime = (Calendar) deserializer.deserialize(ZclDataType.UTCTIME);
        tariffType = (Integer) deserializer.deserialize(ZclDataType.BITMAP_8_BIT);
        co2Value = (Integer) deserializer.deserialize(ZclDataType.UNSIGNED_32_BIT_INTEGER);
        co2ValueUnit = (Integer) deserializer.deserialize(ZclDataType.ENUMERATION_8_BIT);
        co2ValueTrailingDigit = (Integer) deserializer.deserialize(ZclDataType.BITMAP_8_BIT);
    }

    @Override
    public String toString() {
        final StringBuilder builder = new StringBuilder(248);
        builder.append("PublishCo2ValueCommand [");
        builder.append(super.toString());
        builder.append(", providerId=");
        builder.append(providerId);
        builder.append(", issuerEventId=");
        builder.append(issuerEventId);
        builder.append(", startTime=");
        builder.append(startTime);
        builder.append(", tariffType=");
        builder.append(tariffType);
        builder.append(", co2Value=");
        builder.append(co2Value);
        builder.append(", co2ValueUnit=");
        builder.append(co2ValueUnit);
        builder.append(", co2ValueTrailingDigit=");
        builder.append(co2ValueTrailingDigit);
        builder.append(']');
        return builder.toString();
    }

}
